﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using HKEA.CMS.Core.BLL;
using HKEA.CMS.Core.Models;
using HKEA.CMS.Core.Utility;

namespace WebApplication
{
    public partial class MasertTemplates : System.Web.UI.MasterPage
    {
        private string current_language = Common.LanguageInfo.CNLanguage;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //设置当前的页面语言
                SetLanguge(current_language);

                if (Session[Constant.SessionName.Manage] == null)
                {
                    //GetNextUrl();
                    //Response.Redirect(Constant.MainPage.login);
                }
            }
        }

        protected void blLogout_Click(object sender, EventArgs e)
        {
            Session.Clear();
            Response.Redirect(Constant.MainPage.login);
        }

        protected void GetNextUrl()
        {
            if (Request != null)
                Session[Constant.SessionName.NextUrl] = HttpContext.Current.Request.Url.PathAndQuery.ToString().Replace("/","");
            else
                Session[Constant.SessionName.NextUrl] = Constant.MainPage.index;            
        }

        private void SetLanguge(string language)
        {
            Common.LanguageInfo.SetLanguageCookie(language);
        }
    }
}